package createThread;

import java.util.ArrayList;
import java.util.LinkedList;

/**
 * @program: javase
 * @description: 实现Runnable接口
 * @author: lld
 * @create: 2021-03-13 16:28
 **/
class MyThread2 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (i % 2 == 0) {
                try {
                    Thread.sleep(1000);
                    System.out.println("Thread.currentThread().getState() = " + Thread.currentThread().getState());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(i+Thread.currentThread().getName());
            }
        }
    }
}

public class Thread2 {
    public static void main(String[] args) {
        MyThread2 t = new MyThread2();
        Thread thread=new Thread(t);//子线程
        thread.start();
        //主线程
        for (int i = 0; i < 100; i++) {
            if (i % 3 == 0) {
                System.out.println(i + Thread.currentThread().getName());
            }
        }
    }
}
